package com.hnust.controller;
import com.hnust.service.getTestRecordService;
import com.hnust.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin("*") //解决跨域问题
@RestController
public class getTestRecordController {
    @Autowired
    private getTestRecordService getTestRecordService;
    @GetMapping("/test/TestRecord")
    public Result<Object> getTestRecord(@RequestParam("testID") String testID) {
        List list = getTestRecordService.getTestRecord(testID);
        //questionList [] list = getTestRecordService.getTestRecord(testID);
        Map<String, List> map = new HashMap<String, List>() ;
        //Map<String, questionList[]> map = new HashMap<>() ;
        if(list!=null&&list.size()>0) {              //判断是否从数据库拿到数据
            map.put("questionList",list);
            return new Result<Object>(200,"登录成功",map);
        } else {
            return new Result<Object>(500,"未知错误",null);
        }

    }
}
